<template>
  <div>
      <h1 v-test>这是测试自定义指令的</h1>
      <button @click="fun()">点我逆向传值</button>
  </div>
</template>

<script>
export default {
    methods:{
        fun(){
            this.$emit("send","我是子组件传的数据")
        }
    },
    directives:{
        test:{
            inserted(el){
                el.style.color="green"
            }
        }
    }
}
</script>

<style scoped>
h1{
    font-size:0.2rem
}
button{
    font-size:0.18rem
}
</style>